<template>
	<view>
		<nav-bar fontColor="#FFFFFF" title=""></nav-bar>
		<!-- <mescroll-body @init="mescrollInit" @down="downCallback" @up="getDataList1"> -->
			<view class="orderNumber">数量：{{dataList1.length}}个</view>
			<view v-for="(item,index) in dataList1">
				<uni-list>
					<evan-checkbox-group :max="1" style="padding: 20rpx;" @change="changeData" v-model="checkData1">
						<evan-checkbox :key="item.order_id" :label="item.order_id"></evan-checkbox>
						<uni-list-item :index="index+1"
							:title="'订单号:'+item.order_id + '\n' + '商品信息：' + JSON.parse(item.products)[0].product_name + '\n' + '数量：' + JSON.parse(item.products)[0].product_qty"
							:note="'订单总额:'+item.order_amount + '\n'+ '下单时间:'+item.order_date" link="reLaunch" clickable>
						</uni-list-item>
					</evan-checkbox-group>
				</uni-list>
			</view>
		<!-- </mescroll-body> -->


		<view style="height: 120rpx;">
			<view class="bottomBox">
				<view class="buttonBox">
					<!-- <button class="button_fix" size="default" @click="getNew">获取最新融资订单凭证</button> -->
					<button class="button_fix" size="default" @click="confirmAdd">确定添加</button>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';
	export default {
		mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
		data() {
			return {
				dataList1: [],
				checkData1: [],
				total1: ''
			}
		},
		onShow(){
			uni.showLoading({
				title:'加载中...'
			});
			this.getDataList();
		},
		methods: {
			changeData(e) {
				console.log(e)
			},
			confirmAdd() {
				let choosenData = []
				for (let i in this.dataList1) {
					if (this.checkData1[0] == this.dataList1[i].order_id) {
						choosenData.push(this.dataList1[i])
					}
				}
				uni.$emit('confirmOrder', choosenData)
				uni.navigateBack({
					delta: 1
				})
			},
			getDataList(){
				let that = this;
				let opt = {
					url: 'order/salesOrder/hzOrderList/' + '1' + '/100',
					method: 'POST'
				};
				//status测试环境是null，正式环境是8！
				let params = {
					"uscc": uni.getStorageSync('userInfo').customerId,
					"order_status": 8,
					"isfp": "1"
				};
				that.$http.httpTokenRequest(opt, params).then(res => {
					if (res.data.code == 200) {
						that.dataList1 = []
						console.log(res.data.data['$data-detail'])
						for(let i in  res.data.data['$data-detail']){
							if(res.data.data['$data-detail'][i].serviceFeeStatus != 'PAID'){
								that.dataList1.push(res.data.data['$data-detail'][i])
							}
							else{
								console.log(res.data.data['$data-detail'][i].serviceFeeStatus)
							}
						}
						uni.hideLoading();
					} else {
						uni.hideLoading();
						uni.showToast({
							title: res.data.msg,
							icon: 'error',
							duration: 2000
						});
					}
				})
			},
			getDataList1(page) {
				let that = this;
				let opt = {
					url: 'order/salesOrder/hzOrderList/' + page.num + '/10',
					method: 'POST'
				};
				//status测试环境是null，正式环境是8！
				let params = {
					"uscc": uni.getStorageSync('userInfo').customerId,
					// "order_status": 8,
					// "isfp": "1"
				};
				that.$http.httpTokenRequest(opt, params).then(res => {
					if (res.data.code == 200) {
						that.mescroll.endByPage(res.data.data['$data-detail'].length, res.data.data[
							'$data-total-count']); //必传参数(当前页的数据个数, 总页数)
						that.total1 = res.data.data['$data-total-count']
						if (page.num == 1) {
							that.dataList1 = res.data.data['$data-detail'];

						} else {
							that.dataList1 = that.dataList1.concat(res.data.data['$data-detail']);
						}
						if (res.data.data['$data-detail'] == '') {
							// this.messageToggle('error', '暂无数据')
						}
						uni.hideLoading()
					} else {
						uni.hideLoading()
						that.mescroll.endErr();
						uni.showToast({
							title: res.data.msg,
							icon: 'error',
							duration: 2000
						});
					}
				}).catch(() => {
					//联网失败, 结束加载
					that.mescroll.endErr();
				})
			},
			getNew() {
				this.getDataList();
				// this.mescroll.resetUpScroll();
			}
		}
	}
</script>

<style>
	page {
		background: #fafafa;
	}

	.topStep {
		display: flex;
		width: 100%;
		height: 150rpx;
		background: #fff;
		align-items: center;
	}

	.orderNumber {
		text-align: center;
		padding: 30rpx;
		font-size: 30rpx;
		letter-spacing: 3rpx;
		font-weight: 700;
		// font-family: '宋体';
		// font-weight: ;
	}

	.centerBoxtitle {
		font-size: 35rpx;
		color: #000000;
		font-weight: bold;
		margin: 28rpx;

	}

	.example {
		padding: 20rpx;
		background: #fff;
	}

	.bottomBox {
		position: fixed;
		width: 100%;
		bottom: 0;
		margin-bottom: 20rpx;
	}

	.buttonBox {
		width: 100%;
		margin: 0 auto;
		display: flex;
		justify-content: space-around;

		// margin-top: 200rpx;
	}

	.button_fix {
		width: 80%;
		height: 70rpx;
		// margin: 0 auto;
		color: #FFFFFF;
		background: #2749C8;
		font-weight: bold;
		letter-spacing: 5rpx;
		font-size: 28rpx;
		line-height: 70rpx;
	}
</style>